### 2. 魔法学院学生魔法对决

import random

# 定义魔法学生类
class MagicStudent:
    def __init__(self, name, magic_power, spell_list):
        self.name = name
        self.magic_power = magic_power
        self.spell_list = spell_list
        self.health = 100

    def cast_spell(self, other_student):
        spell = random.choice(self.spell_list)
        spell_power = self.magic_power * random.uniform(0.8, 1.2)
        other_student.health -= spell_power
        print(f"{self.name} 对 {other_student.name} 施展了 {spell}，造成了 {spell_power:.2f} 点伤害！")
        if other_student.health <= 0:
            print(f"{other_student.name} 被打败了！")
        else:
            print(f"{other_student.name} 还剩下 {other_student.health:.2f} 点生命值。")

# 创建魔法学生对象
harry = MagicStudent("哈利", 20, ["火焰咒", "冰冻咒", "闪电咒"])
hermione = MagicStudent("赫敏", 25, ["治愈咒", "变形咒", "护盾咒"])

# 模拟魔法对决
print("魔法对决开始！")
while harry.health > 0 and hermione.health > 0:
    if random.choice([True, False]):
        harry.cast_spell(hermione)
    else:
        hermione.cast_spell(harry)
